$(document).ready(function() {
	$('#data').datetimepicker({
		timeFormat: 'HH:mm:ss',
		dateFormat: "dd/mm/yy",
		stepHour: 2,
		stepMinute: 10,
		stepSecond: 10
	});
	$('#example').dataTable( {
		"bDestroy": true,
		"bProcessing": true,
		"bServerSide": true,
		"sAjaxSource": "ajax_consultaLaudosAtivos.php",
		"aaSorting": [[ 0, "desc" ],[ 3, "asc" ]],
		"sScrollY": 200,
		"bJQueryUI": true,
		"bLengthChange": false,
		"bPaginate": false,
		/*"sPaginationType": "full_numbers",*/
		"oLanguage": {
			"LengthMenu": "_MENU_ records per page",
			"sUrl": "../../js/datatable_language.txt"
		}
	});
	/*$('#marcar-todos').click(function(){
		$('table > tbody > tr > td > :checkbox')
		  .attr('checked', $(this).is(':checked'))
		  .trigger('change');
	  });*/
/* **** FORM DIALOG CADASTRO LAUDO**** */
/*
$( "#dialog-form" ).dialog({
	  autoOpen: false,
	  height: 400,
	  width: 650,
	  modal: true,
	  buttons: {
		"Agendar": function() {
		  var bValid = true;
		  alert("teste");
		},
		Cancel: function() {
		  $(this).dialog( "close" );
		}
	  }
	});*/
});

function btn_adicionarLaudo() {
		$("#dialog-form" ).data("url", "teste").dialog("open");
}
function btn_finalizarLaudo(id) {
	var dados = "id="+id;
	
	$.ajax({  
		type: "POST",  
		url: "_finalizar_laudo.php",  
		data: dados,  
		success: function(data)  
		{  
			alert( data );
			window.location.href = "consultas.php";
		},
		statusCode: {
			404: function() {
			  alert("Pagina nao encontrada");
			  window.location.href = "consultas.php";
			}
		}
	});  
}
function OpenDialog(id) {
	$('#dialog-form').dialog({
		autoOpen: false,
		modal: true,
		open: function(event, ui) {
			var data = id;
		},
		buttons: {
			'Save': function() {
				alert(data);
			},
		   
		}
	});
	$('#dialog-form').dialog('open');
}
function btn_acao(pagina,id) {
	var theForm, id;
	// Start by creating a <form>
	theForm = document.createElement('form');
	theForm.action = pagina;
	theForm.method = 'POST';
	// Next create the <input>s in the form and give them names and values
	input = document.createElement('input');
	input.type = 'hidden';
	input.name = 'id';
	input.value = id;
	
	// Now put everything together...
	theForm.appendChild(input);
	
	// ...and it to the DOM...
	document.getElementById('hidden_form_container').appendChild(theForm);
	// ...and submit it
	theForm.submit();
}
function btn_acao1(pagina,id) {
	var theForm, id;
	// Start by creating a <form>
	theForm = document.createElement('form');
	theForm.action = pagina;
	theForm.method = 'POST';
	theForm.target = '_blank';
	// Next create the <input>s in the form and give them names and values
	input = document.createElement('input');
	input.type = 'hidden';
	input.name = 'id';
	input.value = id;
	
	// Now put everything together...
	theForm.appendChild(input);
	
	// ...and it to the DOM...
	document.getElementById('hidden_form_container').appendChild(theForm);
	// ...and submit it
	theForm.submit();
}